#ifndef  __UARTPROTOCOL_H__
#define  __UARTPROTOCOL_H__

#include  "WirelessProtocol.h"


#define  UARTPROTOCOL_DOWN_NO_ERR                           (0x01)
#define  UARTPROTOCOL_DOWN_ERR_LRC                          (0x02)
#define  UARTPROTOCOL_DOWN_ERR_NODATA                       (0x03)
#define  UARTPROTOCOL_DOWN_ERR_READERID_MISMATCH            (0x04)
#define  UARTPROTOCOL_DOWN_ERR_PROTOCOLID_MISMATCH          (0x05)                     

#define  UARTPROTOCOL_CMD_RD_ESEAL_ID                       (0x20)
#define  UARTPROTOCOL_CMD_RD_ESEAL_EVENT                    (0x21)
#define  UARTPROTOCOL_CMD_RD_ESEAL_EVENTNUM                 (0x22)
#define  UARTPROTOCOL_CMD_SET_INOUT                         (0x23)
#define  UARTPROTOCOL_CMD_OPERAT_READER                     (0x24)
#define  UARTPROTOCOL_CMD_OPERAT_OVER_READER                (0x25)
#define  UARTPROTOCOL_CMD_RD_ESEAL_RTC                      (0x26)
#define  UARTPROTOCOL_CMD_SET_READER                        (0xA0)

#define  UARTPROTOCOL_DOWN_DEFAULT_LENGTH                   (3)
#define  UARTPROTOCOL_DOWN_DATA_MAX_LENGTH                  (3)

#define  UART_COMM_SUCCESS                                  (0x00)
#define  UART_COMM_ERR_LRC                                  (0x01)
#define  UART_COMM_ERR_OTHER                                (0x03)
            
#define  UARTFRAME_DATA_POS_CMD                             (0)
#define  UARTFRAME_DATA_POS_CMD_OPTION                      (UARTFRAME_DATA_POS_CMD + 1)


typedef  struct __uart_rx_frame
{
    INT8U  ReaderID[FRAME_DATA_LTH_READERID];
    INT8U  Length;
    INT8U  Data[UARTPROTOCOL_DOWN_DATA_MAX_LENGTH];
}UART_RX_FRAME;

extern UART_RX_FRAME  uart_rxBuf;

INT8U  UartProtocol_RecvPacket(UART_RX_FRAME* pUartRecvPacket);
INT8U  UartProtocol_AnswerPacket(UART_RX_FRAME* pUartRecvPacket);
UART_RX_FRAME*   UartProtocol_ParsePacket(UART_RX_FRAME* pUartRecvPacket);

#endif

